package com.wgchao.authodemo.infrastructure.jpa.base;

import com.wgchao.authodemo.domian.entity.base.AgencyDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @作者  wgchao
 * @时间 2019-12-10 
 * @用途  
 */
@Repository
public interface AgencyRepository  extends JpaRepository<AgencyDO, Long>, JpaSpecificationExecutor<AgencyDO> {

    AgencyDO findFirstByCode(String code);

    List<AgencyDO> findAllByCodeLikeOrderByCode(String code);

    @Query("select max(code) from AgencyDO where parAgencyCode=?1")
    public String findNextChildCode(String parentCode);

}
